import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import common.QuestionDetails;
import common.QuestionManager;
import common.SQLCall;


public class Tester
{
	private static Connection conn;
	
	public static void main(String[] args) throws SQLException {
		connect();
		
		QuestionManager qm = SQLCall.getQuestionManager(conn);

		close();
		
		int total = 20;
		int cat   = 4;

		System.out.println("Cat ----- "+cat);
		while(total > 0) {
		
			QuestionDetails qd = qm.getQuestion(cat, total);
			
			System.out.println("ID    : "+qd.getID());
			System.out.println("Points: "+qd.getPoints());
			
			total -= qd.getPoints();
		}

		total = 30;
		cat   = 3;
		System.out.println("Cat ----- "+cat);
		while(total > 0) {
			
			QuestionDetails qd = qm.getQuestion(cat, total);
			
			System.out.println("ID    : "+qd.getID());
			System.out.println("Points: "+qd.getPoints());
			
			total -= qd.getPoints();
		}

		total = 20;
		cat   = 2;
		System.out.println("Cat ----- "+cat);
		while(total > 0) {
		
			QuestionDetails qd = qm.getQuestion(cat, total);
			
			System.out.println("ID    : "+qd.getID());
			System.out.println("Points: "+qd.getPoints());
			
			total -= qd.getPoints();
		}

		total = 30;
		cat   = 1;
		System.out.println("Cat ----- "+cat);
		while(total > 0) {
		
			QuestionDetails qd = qm.getQuestion(cat, total);
			
			System.out.println("ID    : "+qd.getID());
			System.out.println("Points: "+qd.getPoints());
			
			total -= qd.getPoints();
		}
		
		
	}
	
	public static void connect() throws SQLException
	{
		DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
		conn = DriverManager.getConnection(
				"jdbc:oracle:thin:@146.187.134.17:1542:oracle10g", "cscd494",
				"R3tral435");
	}
	
	public static void close() throws SQLException
	{
		conn.close();// Close database connection
	}
}
